.class public Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;
.super Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaController;
.source "OrmmaAssetController.java"


# static fields
.field private static final LOG:Lcom/burstly/lib/util/LoggerExt; = null

.field private static final TAG:Ljava/lang/String; = "OrmmaAssetController"


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 31
    invoke-static {}, Lcom/burstly/lib/util/LoggerExt;->getInstance()Lcom/burstly/lib/util/LoggerExt;

    move-result-object v0

    sput-object v0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    return-void
.end method

.method public constructor <init>(Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaView;Landroid/content/Context;)V
    .locals 0
    .parameter "adView"
    .parameter "context"

    .prologue
    .line 45
    invoke-direct {p0, p1, p2}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaController;-><init>(Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaView;Landroid/content/Context;)V

    .line 46
    return-void
.end method

.method public static deleteDirectory(Ljava/io/File;)Z
    .locals 3
    .parameter "path"

    .prologue
    .line 220
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v2

    if-eqz v2, :cond_1

    .line 221
    invoke-virtual {p0}, Ljava/io/File;->listFiles()[Ljava/io/File;

    move-result-object v0

    .line 222
    .local v0, files:[Ljava/io/File;
    const/4 v1, 0x0

    .local v1, i:I
    :goto_0
    array-length v2, v0

    if-ge v1, v2, :cond_1

    .line 223
    aget-object v2, v0, v1

    invoke-virtual {v2}, Ljava/io/File;->isDirectory()Z

    move-result v2

    if-eqz v2, :cond_0

    .line 224
    aget-object v2, v0, v1

    invoke-static {v2}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->deleteDirectory(Ljava/io/File;)Z

    .line 222
    :goto_1
    add-int/lit8 v1, v1, 0x1

    goto :goto_0

    .line 226
    :cond_0
    aget-object v2, v0, v1

    invoke-virtual {v2}, Ljava/io/File;->delete()Z

    goto :goto_1

    .line 230
    .end local v0           #files:[Ljava/io/File;
    .end local v1           #i:I
    :cond_1
    invoke-virtual {p0}, Ljava/io/File;->delete()Z

    move-result v2

    return v2
.end method

.method private getFilesDir()Ljava/lang/String;
    .locals 1

    .prologue
    .line 209
    iget-object v0, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->mContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getFilesDir()Ljava/io/File;

    move-result-object v0

    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method private readStream(Ljava/io/InputStream;)Ljava/lang/String;
    .locals 7
    .parameter "in"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 183
    const/16 v5, 0x400

    new-array v0, v5, [B

    .line 184
    .local v0, buff:[B
    new-instance v2, Ljava/io/ByteArrayOutputStream;

    invoke-direct {v2}, Ljava/io/ByteArrayOutputStream;-><init>()V

    .line 186
    .local v2, fromFile:Ljava/io/ByteArrayOutputStream;
    :goto_0
    invoke-virtual {p1, v0}, Ljava/io/InputStream;->read([B)I

    move-result v3

    .line 187
    .local v3, numread:I
    if-gtz v3, :cond_0

    .line 192
    invoke-virtual {v2}, Ljava/io/ByteArrayOutputStream;->toString()Ljava/lang/String;

    move-result-object v4

    .line 194
    .local v4, wholeHtml:Ljava/lang/String;
    :try_start_0
    invoke-virtual {v2}, Ljava/io/ByteArrayOutputStream;->close()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    .line 199
    :goto_1
    const/4 v2, 0x0

    .line 200
    return-object v4

    .line 190
    .end local v4           #wholeHtml:Ljava/lang/String;
    :cond_0
    const/4 v5, 0x0

    invoke-virtual {v2, v0, v5, v3}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    goto :goto_0

    .line 196
    .restart local v4       #wholeHtml:Ljava/lang/String;
    :catch_0
    move-exception v1

    .line 197
    .local v1, e:Ljava/io/IOException;
    sget-object v5, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v6, "OrmmaAssetController"

    invoke-virtual {v5, v6, v1}, Lcom/burstly/lib/util/LoggerExt;->logThrowable(Ljava/lang/String;Ljava/lang/Throwable;)V

    goto :goto_1
.end method


# virtual methods
.method public cacheRemaining()I
    .locals 5
    .annotation runtime Landroid/webkit/JavascriptInterface;
    .end annotation

    .prologue
    .line 55
    iget-object v3, p0, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->mContext:Landroid/content/Context;

    invoke-virtual {v3}, Landroid/content/Context;->getFilesDir()Ljava/io/File;

    move-result-object v0

    .line 56
    .local v0, filesDir:Ljava/io/File;
    new-instance v2, Landroid/os/StatFs;

    invoke-virtual {v0}, Ljava/io/File;->getPath()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Landroid/os/StatFs;-><init>(Ljava/lang/String;)V

    .line 57
    .local v2, stats:Landroid/os/StatFs;
    invoke-virtual {v2}, Landroid/os/StatFs;->getFreeBlocks()I

    move-result v3

    invoke-virtual {v2}, Landroid/os/StatFs;->getBlockSize()I

    move-result v4

    mul-int v1, v3, v4

    .line 58
    .local v1, free:I
    return v1
.end method

.method public deleteOldAds()V
    .locals 4

    .prologue
    .line 237
    invoke-direct {p0}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->getFilesDir()Ljava/lang/String;

    move-result-object v1

    .line 238
    .local v1, filesDir:Ljava/lang/String;
    new-instance v0, Ljava/io/File;

    new-instance v2, Ljava/lang/StringBuilder;

    invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v2, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    sget-object v3, Ljava/io/File;->separator:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "ad"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-direct {v0, v2}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    .line 239
    .local v0, adDir:Ljava/io/File;
    invoke-static {v0}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->deleteDirectory(Ljava/io/File;)Z

    .line 240
    return-void
.end method

.method public prepareWrappedContentString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
    .locals 12
    .parameter "wholeHtml"
    .parameter "injection"

    .prologue
    const/4 v7, 0x0

    .line 84
    const-string v8, "<html"

    invoke-virtual {p1, v8}, Ljava/lang/String;->indexOf(Ljava/lang/String;)I

    move-result v8

    if-ltz v8, :cond_1

    const/4 v1, 0x1

    .line 85
    .local v1, hasHtmlWrap:Z
    :goto_0
    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6, p1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    .line 86
    .local v6, wholeHtmlBuffer:Ljava/lang/StringBuilder;
    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    .line 87
    .local v3, out:Ljava/lang/StringBuilder;
    invoke-static {}, Lcom/burstly/lib/constants/UriConstants;->getInstance()Lcom/burstly/lib/constants/UriConstants;

    move-result-object v5

    .line 88
    .local v5, uriConstants:Lcom/burstly/lib/constants/UriConstants;
    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5}, Lcom/burstly/lib/constants/UriConstants;->getContentRoot()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "/lib/ormma_android_v1.js"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 89
    .local v2, ormmaPath:Ljava/lang/String;
    new-instance v8, Ljava/lang/StringBuilder;

    invoke-direct {v8}, Ljava/lang/StringBuilder;-><init>()V

    invoke-virtual {v5}, Lcom/burstly/lib/constants/UriConstants;->getContentRoot()Ljava/lang/String;

    move-result-object v9

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    const-string v9, "/lib/ormma_bridge_android_v1.js"

    invoke-virtual {v8, v9}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v8

    invoke-virtual {v8}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    .line 92
    .local v0, bridgePath:Ljava/lang/String;
    if-eqz v1, :cond_4

    .line 93
    const-string v8, "/ormma_bridge.js"

    invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->indexOf(Ljava/lang/String;)I

    move-result v4

    .line 94
    .local v4, start:I
    if-lez v4, :cond_2

    .line 99
    :goto_1
    const-string v8, "/ormma.js"

    invoke-virtual {v6, v8}, Ljava/lang/StringBuilder;->indexOf(Ljava/lang/String;)I

    move-result v4

    .line 100
    if-lez v4, :cond_3

    .line 121
    .end local v4           #start:I
    :goto_2
    invoke-virtual {v3, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/CharSequence;)Ljava/lang/StringBuilder;

    .line 122
    if-nez v1, :cond_0

    .line 123
    const-string v7, "</div> "

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 124
    const-string v7, "</body> "

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 125
    const-string v7, "</html> "

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 127
    :cond_0
    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    return-object v7

    .end local v0           #bridgePath:Ljava/lang/String;
    .end local v1           #hasHtmlWrap:Z
    .end local v2           #ormmaPath:Ljava/lang/String;
    .end local v3           #out:Ljava/lang/StringBuilder;
    .end local v5           #uriConstants:Lcom/burstly/lib/constants/UriConstants;
    .end local v6           #wholeHtmlBuffer:Ljava/lang/StringBuilder;
    :cond_1
    move v1, v7

    .line 84
    goto :goto_0

    .line 97
    .restart local v0       #bridgePath:Ljava/lang/String;
    .restart local v1       #hasHtmlWrap:Z
    .restart local v2       #ormmaPath:Ljava/lang/String;
    .restart local v3       #out:Ljava/lang/StringBuilder;
    .restart local v4       #start:I
    .restart local v5       #uriConstants:Lcom/burstly/lib/constants/UriConstants;
    .restart local v6       #wholeHtmlBuffer:Ljava/lang/StringBuilder;
    :cond_2
    sget-object v8, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v9, "OrmmaAssetController"

    const-string v10, "ormma_bridge.js script hasn`t been found in HTML!"

    new-array v11, v7, [Ljava/lang/Object;

    invoke-virtual {v8, v9, v10, v11}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_1

    .line 103
    :cond_3
    sget-object v8, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->LOG:Lcom/burstly/lib/util/LoggerExt;

    const-string v9, "OrmmaAssetController"

    const-string v10, "ormma.js script hasn`t been found in HTML!"

    new-array v7, v7, [Ljava/lang/Object;

    invoke-virtual {v8, v9, v10, v7}, Lcom/burstly/lib/util/LoggerExt;->logError(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    goto :goto_2

    .line 106
    .end local v4           #start:I
    :cond_4
    const-string v7, "<html>"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 107
    const-string v7, "<head>"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 108
    const-string v7, "<meta name=\'viewport\' content=\'user-scalable=no initial-scale=1.0\' />"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 109
    const-string v7, "<title>Advertisement</title> "

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 110
    const-string v7, "<script src=\""

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "\" type=\"text/javascript\"></script>"

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 111
    const-string v7, "<script src=\""

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    invoke-virtual {v7, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v7

    const-string v8, "\" type=\"text/javascript\"></script>"

    invoke-virtual {v7, v8}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 112
    if-eqz p2, :cond_5

    .line 113
    const-string v7, "<script type=\"text/javascript\">"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 114
    invoke-virtual {v3, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 115
    const-string v7, "</script>"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 117
    :cond_5
    const-string v7, "</head>"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 118
    const-string v7, "<body style=\"margin:0; padding:0; overflow:hidden; background-color:transparent;\">"

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    .line 119
    const-string v7, "<div align=\"center\"> "

    invoke-virtual {v3, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    goto/16 :goto_2
.end method

.method public readStreamAndPrepareWrappedContentString(Ljava/io/InputStream;Ljava/lang/String;)Ljava/lang/String;
    .locals 2
    .parameter "in"
    .parameter "injection"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .line 71
    invoke-direct {p0, p1}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->readStream(Ljava/io/InputStream;)Ljava/lang/String;

    move-result-object v0

    .line 72
    .local v0, wholeHtml:Ljava/lang/String;
    invoke-virtual {p0, v0, p2}, Lcom/burstly/lib/component/networkcomponent/burstly/html/ormma/OrmmaAssetController;->prepareWrappedContentString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    return-object v1
.end method

.method public stopAllListeners()V
    .locals 0

    .prologue
    .line 244
    return-void
.end method
